package com.jucai.pppeiyouclient.adapter;

import android.content.Context;

import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.base.CommonRecyclerViewAdapter;
import com.jucai.pppeiyouclient.bean.ActivityEvaluationBean;

import java.util.List;

/**
 * Created by Kuky on 2017-05-07.
 */

public class ActEvaluationAdapter extends CommonRecyclerViewAdapter<ActivityEvaluationBean> {
    public ActEvaluationAdapter(Context context, List<ActivityEvaluationBean> data) {
        super(context, data);
    }

    @Override
    public void bindHolder(CommonHolder holder, ActivityEvaluationBean activityEvaluationBean) {
        holder.setImage(R.id.act_eval_img, activityEvaluationBean.getMember_avatar(), 60, 60);
        holder.setText(R.id.act_eval_nick, activityEvaluationBean.getMember_realname());
        holder.setText(R.id.act_evaluation, "评语：" + activityEvaluationBean.getEvaluation_conent());
        List<String> imgUrls = activityEvaluationBean.getEvaluation_img_list();

        if (!imgUrls.isEmpty() && imgUrls != null) {
            if (imgUrls.size() == 1) {
                holder.setImage(R.id.act_eval_pic_01, imgUrls.get(0), 45, 35);
                holder.setInvisible(R.id.act_eval_pic_02);
                holder.setInvisible(R.id.act_eval_pic_03);
            } else if (imgUrls.size() == 2) {
                holder.setImage(R.id.act_eval_pic_01, imgUrls.get(0), 45, 35);
                holder.setImage(R.id.act_eval_pic_02, imgUrls.get(1), 45, 35);
                holder.setInvisible(R.id.act_eval_pic_03);
            } else if (imgUrls.size() >= 3) {
                holder.setImage(R.id.act_eval_pic_01, imgUrls.get(0), 45, 35);
                holder.setImage(R.id.act_eval_pic_02, imgUrls.get(1), 45, 35);
                holder.setImage(R.id.act_eval_pic_03, imgUrls.get(2), 45, 35);
            }
        } else {
            holder.setInvisible(R.id.act_eval_ll);
        }
    }

    @Override
    protected int getItemType(int position) {
        return 0;
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_activity_evaluation_layout;
    }
}
